package com.qf.blog.controller;

import com.qf.blog.entity.User;
import com.qf.blog.service.FollowVoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping ("/follow")
public class FollowController {
    @Autowired
    private FollowVoService followVoService;

    @RequestMapping ("/following/{userId}")
    public String getFollowing(@PathVariable Integer userId, HttpServletRequest request) {
        List<User> followingList = followVoService.getFollowing(userId);
        request.setAttribute("followingList", followingList);
        return "site/following";
    }

    @RequestMapping ("/follower/{userId}")
    public String getFollower(@PathVariable Integer userId, HttpServletRequest request) {
        List<User> followerList = followVoService.getFollower(userId);
        request.setAttribute("followerList", followerList);
        return "site/follower";
    }
}
